package com.tools.developer;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class SystemInfoActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.four_device_info);
		String result = getSystemProperty();
		TextView cpu_mem_info = (TextView) findViewById(R.id.info_text);

		cpu_mem_info.setText(result);

		getSysTime();

	}

	/**
	 * 获取与系统有关的时间
	 */
	private void getSysTime() {
		TextView elapsedT = (TextView) findViewById(R.id.sys_info_elapsed_realtime);
		long elapsedRT = android.os.SystemClock.elapsedRealtime();
		elapsedT.setText(getString(R.string.sys_info_elapsed_realtime,
				String.valueOf(elapsedRT)));

		TextView uptime = (TextView) findViewById(R.id.sys_info_uptime_millis);
		long uptimeMs = android.os.SystemClock.uptimeMillis();

		uptime.setText(getString(R.string.sys_info_uptime_millis,
				String.valueOf(uptimeMs)));

		TextView sleepT = (TextView) findViewById(R.id.sys_info_sleep_time);
		
		sleepT.setText(getString(R.string.sys_info_sleep_time,
				String.valueOf(elapsedRT - uptimeMs)));
	}

	public static StringBuffer buffer = null;

	private static String initProperty(String description, String propertyStr) {
		if (buffer == null) {
			buffer = new StringBuffer();
		}
		buffer.append(description).append(":");
		buffer.append(System.getProperty(propertyStr)).append("\n");
		return buffer.toString();
	}

	private static String getSystemProperty() {
		buffer = new StringBuffer();
		initProperty("java.vendor.url", "java.vendor.url");
		initProperty("java.class.path", "java.class.path");

		return buffer.toString();
	}

}
